const Koa = require('koa')
const Router = require('@koa/router')
const cors = require('koa2-cors')
const bodyParser = require('koa-bodyparser')
const app = new Koa()
const list = require('./list.json')
const router = new Router({
    prefix: '/api'
})

app.use(cors())
app.use(bodyParser())

router.post('/', (ctx, next) => {
    // ctx.router available
    ctx.body = list
})

app.use(router.routes())
   .use(router.allowedMethods())

app.listen(3005, () => {
    console.log('服务已启动: http://localhost:3005');
})